#include "GnSystemPCH.h"
#include "GnSystem.h"

//--------------------------------------------------------------------------------------------------
float GnGetCurrentTimeInSec()
{
	static bool bFirst = true;
	static LARGE_INTEGER freq;
	static LARGE_INTEGER initial;

	if (bFirst)
	{
		QueryPerformanceFrequency(&freq);
		QueryPerformanceCounter(&initial);
		bFirst = false;
	}

	LARGE_INTEGER counter;
	QueryPerformanceCounter(&counter);
	return (float)((long double)
		(counter.QuadPart - initial.QuadPart) / 
		(long double) freq.QuadPart);
}

//--------------------------------------------------------------------------------------------------
unsigned int GnGetFileSize (const char* pFilename)
{
	// get file statistics
	struct _stat info;
	int result = _stat(pFilename,&info);

	if ( result != 0 )
		// could not get statistics (maybe file does not exist)
		return 0;

	return int(info.st_size);
}